Import mojo
Import agfx

Class TSpriteContainer Extends StringMap<TSprite>


	'| ----------------------------------------------------------------------
	'| ADD
	'| ----------------------------------------------------------------------
	Method Add:Void(spr:TSprite)
		Self.Set(spr.name,spr)
	End Method
	
	'| ----------------------------------------------------------------------
	'| FIND
	'| ----------------------------------------------------------------------
	Method Find:TSprite(name:String)
		name = name.ToUpper()
		Local i:TSprite =  Self.Get(name)
		AssertNotNull(i, "Image '" + name + "' not found in the ImageBank")
		Return i
	End
	
	'| ----------------------------------------------------------------------
	'| DUMP names
	'| ----------------------------------------------------------------------
	Method Dump:Void()
		' debug: print all keys in the map
		Local key:String
		For key = EachIn self.Keys()
			Print key + " is stored in the SPRITES map."
		Next
	End
	
	'| ----------------------------------------------------------------------
	'| UPDATE - called from framework
	'| ----------------------------------------------------------------------
	Method Update:Void()
		Local spr:TSprite
		For spr = EachIn self.Values()
			spr.Update()
		Next
	End Method
	
	'| ----------------------------------------------------------------------
	'| RENDER - called from framework
	'| ----------------------------------------------------------------------
	Method Render:Void()
		Local spr:TSprite
		For spr = EachIn self.Values()
			spr.Draw()
		Next
	End Method
	
End Class

